/*                   _   _ _ __                               *\
**     ________ ___ | | | | '_ \   scaup - Scala up!          **
**    / __/ __// _ || | | | |_) |  (c) 2008, Normen Mueller   **
**  __\ \/ /__/ __ || |_| | .__/   http://kwarc.info.nmueller **
** /____/\___/_/ |_/ \__,_|_|                                 **
**                                                            **
\*                                                            */
  
// $Id: VirtualFile.scala 9 2008-05-24 12:12:30Z normen.mueller $

/* This class has its origin at: scala.tools.nsc.io.VirtualFile */

package scaup.io.fs

import java.io.{File, InputStream}

/** This class implements an empty abstract regular file. */
class VirtualFile(val name: String, _path: String) extends AbstractFile {

  assert((name ne null) && (path ne null), name + " - " + path)

  /** Initializes this instance with the specified name and an identical path.
  @param name the name of the virtual file to be created
  @return     the created virtual file */
  def this(name: String) = this(name, name)
  
  override def hashCode = name.hashCode
  override def equals(that : Any) = that match {
    case that : VirtualFile => name == that.name
    case _ => false
  }

  def path = _path

  /** Returns null. */
  final def file: File = null

  def input : InputStream = throw new Error("not supported");
  
  def container : AbstractFile = throw new Error("not supported")

  /** Is this abstract file a directory? */
  def isDirectory: Boolean = false

  /** Returns the time that this abstract file was last modified. */
  def lastModified: Long = Math.MIN_LONG

  /** Returns all abstract subfiles of this abstract directory. */
  def elements: Iterator[AbstractFile] = {
    assert(isDirectory, "not a directory '" + this + "'")
    Iterator.empty
  }

  /** Returns the abstract file in this abstract directory with the specified name. If there is no such file, returns null. The argument "directory" tells whether to look
  for a directory or a regular file.
  @param name      ...
  @param directory ...
  @return          ...*/
  def lookupName(name: String, directory: Boolean): AbstractFile = {
    assert(isDirectory, "not a directory '" + this + "'")
    null
  }
}
